<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>命名规范 | 孙加俊的个人博客</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link rel="icon" href="/sjj-blog/favicon.ico">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/sjj-blog/assets/css/0.styles.a5cb6817.css" as="style"><link rel="preload" href="/sjj-blog/assets/js/app.ab5bad9b.js" as="script"><link rel="preload" href="/sjj-blog/assets/js/3.136f62ef.js" as="script"><link rel="preload" href="/sjj-blog/assets/js/1.a27fba8e.js" as="script"><link rel="preload" href="/sjj-blog/assets/js/18.2237a65f.js" as="script"><link rel="prefetch" href="/sjj-blog/assets/js/10.9271e5b8.js"><link rel="prefetch" href="/sjj-blog/assets/js/11.67b9ea44.js"><link rel="prefetch" href="/sjj-blog/assets/js/12.f69e6353.js"><link rel="prefetch" href="/sjj-blog/assets/js/13.ace41b19.js"><link rel="prefetch" href="/sjj-blog/assets/js/14.78670b1e.js"><link rel="prefetch" href="/sjj-blog/assets/js/15.b0aaec82.js"><link rel="prefetch" href="/sjj-blog/assets/js/16.f0d479dc.js"><link rel="prefetch" href="/sjj-blog/assets/js/17.1bacbab3.js"><link rel="prefetch" href="/sjj-blog/assets/js/19.7e0f4bf8.js"><link rel="prefetch" href="/sjj-blog/assets/js/20.5c098df8.js"><link rel="prefetch" href="/sjj-blog/assets/js/21.45bd5038.js"><link rel="prefetch" href="/sjj-blog/assets/js/4.cc582e42.js"><link rel="prefetch" href="/sjj-blog/assets/js/5.9c9443fe.js"><link rel="prefetch" href="/sjj-blog/assets/js/6.370fb6dd.js"><link rel="prefetch" href="/sjj-blog/assets/js/7.e5d26899.js"><link rel="prefetch" href="/sjj-blog/assets/js/8.f6b78670.js"><link rel="prefetch" href="/sjj-blog/assets/js/9.d915a2b8.js">
    <link rel="stylesheet" href="/sjj-blog/assets/css/0.styles.a5cb6817.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar" data-v-1aefc0b4><div data-v-1aefc0b4><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-1aefc0b4 data-v-1aefc0b4><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-25ba6db2 data-v-1aefc0b4 data-v-1aefc0b4><h3 class="title" data-v-25ba6db2 data-v-25ba6db2>孙加俊的个人博客</h3> <p class="description" data-v-25ba6db2 data-v-25ba6db2></p> <label id="box" class="inputBox" data-v-25ba6db2 data-v-25ba6db2><input type="password" value="" data-v-25ba6db2> <span data-v-25ba6db2>Konck! Knock!</span> <button data-v-25ba6db2>OK</button></label> <div class="footer" data-v-25ba6db2 data-v-25ba6db2><span data-v-25ba6db2><i class="iconfont reco-theme" data-v-25ba6db2></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-25ba6db2>vuePress-theme-reco</a></span> <span data-v-25ba6db2><i class="iconfont reco-copyright" data-v-25ba6db2></i> <a data-v-25ba6db2><span data-v-25ba6db2>孙加俊</span>
            
          <span data-v-25ba6db2>2017 - </span>
          2023
        </a></span></div></div> <div class="hide" data-v-1aefc0b4><header class="navbar" data-v-1aefc0b4><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/sjj-blog/" class="home-link router-link-active"><img src="/sjj-blog/logo.png" alt="孙加俊的个人博客" class="logo"> <span class="site-name">孙加俊的个人博客</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/sjj-blog/" class="nav-link"><i class="iconfont reco-home"></i>
  首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      技术栈
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/sjj-blog/categories/规范/" class="nav-link"><i class="undefined"></i>
  规范
</a></li><li class="dropdown-item"><!----> <a href="/sjj-blog/categories/原生JS/" class="nav-link"><i class="undefined"></i>
  原生JS
</a></li></ul></div></div><div class="nav-item"><a href="/sjj-blog/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      文档
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/sjj-blog/docs/theme-reco/" class="nav-link"><i class="undefined"></i>
  vuepress-reco
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      联系我
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://gitee.com/sir-jun" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-1aefc0b4></div> <aside class="sidebar" data-v-1aefc0b4><div class="personal-info-wrapper" data-v-39576ba9 data-v-1aefc0b4><img src="/sjj-blog/avatar.png" alt="author-avatar" class="personal-img" data-v-39576ba9> <h3 class="name" data-v-39576ba9>
    孙加俊
  </h3> <div class="num" data-v-39576ba9><div data-v-39576ba9><h3 data-v-39576ba9>11</h3> <h6 data-v-39576ba9>Articles</h6></div> <div data-v-39576ba9><h3 data-v-39576ba9>3</h3> <h6 data-v-39576ba9>Tags</h6></div></div> <ul class="social-links" data-v-39576ba9></ul> <hr data-v-39576ba9></div> <nav class="nav-links"><div class="nav-item"><a href="/sjj-blog/" class="nav-link"><i class="iconfont reco-home"></i>
  首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      技术栈
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/sjj-blog/categories/规范/" class="nav-link"><i class="undefined"></i>
  规范
</a></li><li class="dropdown-item"><!----> <a href="/sjj-blog/categories/原生JS/" class="nav-link"><i class="undefined"></i>
  原生JS
</a></li></ul></div></div><div class="nav-item"><a href="/sjj-blog/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      文档
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/sjj-blog/docs/theme-reco/" class="nav-link"><i class="undefined"></i>
  vuepress-reco
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      联系我
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://gitee.com/sir-jun" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav> <!----> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-25ba6db2 data-v-1aefc0b4><h3 class="title" data-v-25ba6db2 data-v-25ba6db2>命名规范</h3> <!----> <label id="box" class="inputBox" data-v-25ba6db2 data-v-25ba6db2><input type="password" value="" data-v-25ba6db2> <span data-v-25ba6db2>Konck! Knock!</span> <button data-v-25ba6db2>OK</button></label> <div class="footer" data-v-25ba6db2 data-v-25ba6db2><span data-v-25ba6db2><i class="iconfont reco-theme" data-v-25ba6db2></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-25ba6db2>vuePress-theme-reco</a></span> <span data-v-25ba6db2><i class="iconfont reco-copyright" data-v-25ba6db2></i> <a data-v-25ba6db2><span data-v-25ba6db2>孙加俊</span>
            
          <span data-v-25ba6db2>2017 - </span>
          2023
        </a></span></div></div> <div data-v-1aefc0b4><main class="page"><section><div class="page-title"><h1 class="title">命名规范</h1> <div data-v-f875f3fc><i class="iconfont reco-account" data-v-f875f3fc><span data-v-f875f3fc>孙加俊</span></i> <i class="iconfont reco-date" data-v-f875f3fc><span data-v-f875f3fc>7/20/2023</span></i> <!----> <i class="tags iconfont reco-tag" data-v-f875f3fc><span class="tag-item" data-v-f875f3fc>规范</span></i></div></div> <div class="theme-reco-content content__default"><h1 id="命名规范"><a href="#命名规范" class="header-anchor">#</a> 命名规范</h1> <h2 id="命名严谨性"><a href="#命名严谨性" class="header-anchor">#</a> 命名严谨性</h2> <ul><li>代码中的命名严禁使用拼音与英文混合的方式，更不允许直接使用中文的方式。</li> <li>说明：正确的 英文拼写和语法可以让阅读者易于理解，避免歧义。注意，即使纯拼音命名方式也要避免采用
<ul><li>正例：beijing/ luoyang / rmb 等国际通用的名称，可视同英文</li> <li>反例：DaZhePromotion [打折] / getPingfenByName() [评分] / int 某变量 = 3 杜绝完全不规范的缩写，避免望文不知义：</li> <li>反例：AbstractClass “缩写”命名成 AbsClass；condition “缩写”命名成 condi，此类随意缩写严重 降低了代码的可阅读性。</li></ul></li></ul> <h2 id="项目命名"><a href="#项目命名" class="header-anchor">#</a> 项目命名</h2> <table><thead><tr><th>类别</th> <th>规范</th> <th>正例</th> <th>反例</th></tr></thead> <tbody><tr><td>项目命名</td> <td>全部采用小写方式，以中线分隔。</td> <td>my-project</td> <td>my_project</td></tr></tbody></table> <h2 id="目录命名"><a href="#目录命名" class="header-anchor">#</a> 目录命名</h2> <table><thead><tr><th>类别</th> <th>规范</th> <th>正例</th> <th>反例</th></tr></thead> <tbody><tr><td>目录命名</td> <td>全部采用小写方式， 以中划线分隔，有复数结构时，要采用复数命名法， 缩写不用复数。</td> <td>scripts / styles / components / images / utils / layouts / demo-styles / demo-scripts / img / doc</td> <td>script / style / demo_scripts / demoStyles / imgs / docs</td></tr> <tr><td>VUE 的项目中的 components 中的组件目录。</td> <td>使用 kebab-case 命名</td> <td>head-search / page-loading / authorized / notice-icon</td> <td>HeadSearch / PageLoading</td></tr> <tr><td>VUE 的项目中的除 components 组件目录外的所有目录</td> <td>使用 kebab-case 命名。</td> <td>page-one / shopping-car / user-management</td> <td>ShoppingCar / UserManagement</td></tr> <tr><td>REACT 的项目中的 components 中的组件目录。</td> <td>使用大驼峰命名</td> <td>HeadSearch / PageLoading</td> <td>head-search / page-loading / notice_icon</td></tr> <tr><td>REACT 的项目中的除components 组件目录外的所有目录</td> <td>使用中驼峰命名</td> <td>office/ classesManage / workBench</td> <td>page-one / shopping-car / WorkBench</td></tr></tbody></table> <h2 id="js、css、scss、html、png-文件命名"><a href="#js、css、scss、html、png-文件命名" class="header-anchor">#</a> JS、CSS、SCSS、HTML、PNG 文件命名</h2> <table><thead><tr><th>类别</th> <th>规范</th> <th>正例</th> <th>反例</th></tr></thead> <tbody><tr><td>JS、CSS、SCSS、LESS、HTML、PNG 文件命名</td> <td>全部采用小写方式， 以中划线分隔。</td> <td>render-dom.js / signup.css / index.html / variety-change.less</td> <td>renderDom.js / UserManagement.html</td></tr> <tr><td>png、jpeg等其他图片格式文件命名</td> <td>全部采用小写方式， 以下划线分隔。</td> <td>status_pass.png / company_logo.png</td> <td>workbench.png / TopBanner.png</td></tr> <tr><td>JS、CSS、SCSS、HTML、PNG 文件命名</td> <td>全部采用小写方式， 以中划线分隔。</td> <td>render-dom.js / signup.css / index.html / company-logo.png</td> <td>renderDom.js / UserManagement.html</td></tr> <tr><td>JS、CSS、SCSS、HTML、PNG 文件命名</td> <td>全部采用小写方式， 以中划线分隔。</td> <td>render-dom.js / signup.css / index.html / company-logo.png</td> <td>renderDom.js / UserManagement.html</td></tr></tbody></table> <h2 id="classname命名"><a href="#classname命名" class="header-anchor">#</a> ClassName命名</h2> <p>ClassName 的命名应该尽量精短、明确，必须以字母开头命名，且全部字母为小写，单词之间统一使用下划线“_” 连接,</p> <h3 id="基于姓氏命名法-继承-外来"><a href="#基于姓氏命名法-继承-外来" class="header-anchor">#</a> 基于姓氏命名法 （继承 + 外来）</h3> <p>祖先模块不能出现下划线，除了是全站公用模块，如 mod_ 系列的命名：</p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_son<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_son<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
...
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!-- 这个是全站公用模块，祖先模块允许直接出现下划线 --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>mod_info<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>mod_info_son<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>mod_info_son<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
...
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info_son<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info_son<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
  ...
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><p>在子孙模块数量可预测的情况下，严格继承祖先模块的命名前缀</p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_cover<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><p>当子孙模块<strong>超过 4 级或以上</strong>的时候，可以考虑在祖先模块内具有识辨性的独立缩写作为新的子孙模块</p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_cover<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info_user<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info_user_img<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span><span class="token punctuation">&quot;</span></span> <span class="token attr-name">alt</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span><span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
        <span class="token comment">&lt;!-- 这个时候 miui 为 modulename_info_user_img 首字母缩写--&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>miui_tit<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>miui_txt<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
        ...
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info_list<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_cover<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info_user<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info_user_img<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span><span class="token punctuation">&quot;</span></span> <span class="token attr-name">alt</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span><span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info_user_img_tit<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info_user_img_txt<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
        ...
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>modulename_info_list<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><h3 id="模块命名"><a href="#模块命名" class="header-anchor">#</a> 模块命名</h3> <p>全站公共模块：以 mod_ 开头</p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>mod_yours<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><p>业务公共模块：以 业务名_mod_ 开头</p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>paipai_mod_yours<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><h3 id="常用命名推荐"><a href="#常用命名推荐" class="header-anchor">#</a> 常用命名推荐</h3> <p>注意：ad、banner、gg、guanggao 等有机会和广告挂勾的字符不建议直接用来做 ClassName，因为有些浏览器插件（Chrome 的广告拦截插件等）会直接过滤这些类名，因此</p> <p>这种广告的英文或拼音类名不应该出现</p> <p>另外，敏感不和谐字眼也不应该出现，如：</p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>fuck<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>jer<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>sm<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>gcd<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>ass<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>KMT<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><table><thead><tr><th>ClassName</th> <th>含义</th></tr></thead> <tbody><tr><td>about</td> <td>关于</td></tr> <tr><td>account</td> <td>账户</td></tr> <tr><td>arrow</td> <td>箭头图标</td></tr> <tr><td>article</td> <td>文章</td></tr> <tr><td>aside</td> <td>边栏</td></tr> <tr><td>audio</td> <td>音频</td></tr> <tr><td>avatar</td> <td>头像</td></tr> <tr><td>bg,background</td> <td>背景</td></tr> <tr><td>bar</td> <td>栏（工具类）</td></tr> <tr><td>branding</td> <td>品牌化</td></tr> <tr><td>crumb,breadcrumbs</td> <td>面包屑</td></tr> <tr><td>btn,button</td> <td>按钮</td></tr> <tr><td>caption</td> <td>标题，说明</td></tr> <tr><td>card</td> <td>卡片</td></tr> <tr><td>category</td> <td>分类</td></tr> <tr><td>chart</td> <td>图表</td></tr> <tr><td>clearfix</td> <td>清除浮动</td></tr> <tr><td>close</td> <td>关闭</td></tr> <tr><td>col,column</td> <td>列</td></tr> <tr><td>comment</td> <td>评论</td></tr> <tr><td>community</td> <td>社区</td></tr> <tr><td>container</td> <td>容器</td></tr> <tr><td>content</td> <td>内容</td></tr> <tr><td>copyright</td> <td>版权</td></tr> <tr><td>current</td> <td>当前态，选中态</td></tr> <tr><td>default</td> <td>默认</td></tr> <tr><td>description</td> <td>描述</td></tr> <tr><td>details</td> <td>细节</td></tr> <tr><td>disabled</td> <td>不可用</td></tr> <tr><td>entry</td> <td>文章，博文</td></tr> <tr><td>error</td> <td>错误</td></tr> <tr><td>even</td> <td>偶数，常用于多行列表或表格中</td></tr> <tr><td>fail</td> <td>失败（提示）</td></tr> <tr><td>feature</td> <td>专题</td></tr> <tr><td>fewer</td> <td>收起</td></tr> <tr><td>field</td> <td>用于表单的输入区域</td></tr> <tr><td>filter</td> <td>筛选</td></tr> <tr><td>first</td> <td>第一个，常用于列表中</td></tr> <tr><td>footer</td> <td>页脚</td></tr> <tr><td>forum</td> <td>论坛</td></tr> <tr><td>gallery</td> <td>画廊</td></tr> <tr><td>group</td> <td>模块，清除浮动</td></tr> <tr><td>header</td> <td>页头</td></tr> <tr><td>help</td> <td>帮助</td></tr> <tr><td>hide</td> <td>隐藏</td></tr> <tr><td>hightlight</td> <td>高亮</td></tr> <tr><td>home</td> <td>主页</td></tr> <tr><td>icon</td> <td>图标</td></tr> <tr><td>info,information</td> <td>信息</td></tr> <tr><td>last</td> <td>最后一个，常用于列表中</td></tr> <tr><td>links</td> <td>链接</td></tr> <tr><td>login</td> <td>登录</td></tr> <tr><td>logout</td> <td>退出</td></tr> <tr><td>logo</td> <td>标志</td></tr> <tr><td>main</td> <td>主体</td></tr> <tr><td>mask</td> <td>遮罩层</td></tr> <tr><td>menu</td> <td>菜单</td></tr> <tr><td>meta</td> <td>作者、更新时间等信息栏，一般位于标题之下</td></tr> <tr><td>module</td> <td>模块</td></tr> <tr><td>more</td> <td>更多（展开）</td></tr> <tr><td>msg,message</td> <td>消息</td></tr> <tr><td>nav,navigation</td> <td>导航</td></tr> <tr><td>next</td> <td>下一页</td></tr> <tr><td>nub</td> <td>小块</td></tr> <tr><td>odd</td> <td>奇数，常用于多行列表或表格中</td></tr> <tr><td>off</td> <td>鼠标离开</td></tr> <tr><td>on</td> <td>鼠标移过</td></tr> <tr><td>output</td> <td>输出</td></tr> <tr><td>pagination</td> <td>分页</td></tr> <tr><td>pop,popup</td> <td>弹窗</td></tr> <tr><td>picture,pic,image,img</td> <td>图片</td></tr> <tr><td>preview</td> <td>预览</td></tr> <tr><td>previous</td> <td>上一页</td></tr> <tr><td>primary</td> <td>主要</td></tr> <tr><td>progress</td> <td>进度条</td></tr> <tr><td>promotion</td> <td>促销</td></tr> <tr><td>rcommd,recommendations</td> <td>推荐</td></tr> <tr><td>reg,register</td> <td>注册</td></tr> <tr><td>save</td> <td>保存</td></tr> <tr><td>search</td> <td>搜索</td></tr> <tr><td>secondary</td> <td>次要</td></tr> <tr><td>section</td> <td>区块</td></tr> <tr><td>selected</td> <td>已选</td></tr> <tr><td>share</td> <td>分享</td></tr> <tr><td>show</td> <td>显示</td></tr> <tr><td>sidebar</td> <td>边栏，侧栏</td></tr> <tr><td>slide</td> <td>幻灯片，图片切换</td></tr> <tr><td>sort</td> <td>排序</td></tr> <tr><td>sub</td> <td>次级的，子级的</td></tr> <tr><td>submit</td> <td>提交</td></tr> <tr><td>subscribe</td> <td>订阅</td></tr> <tr><td>subtitle</td> <td>副标题</td></tr> <tr><td>success</td> <td>成功（提示）</td></tr> <tr><td>summary</td> <td>摘要</td></tr> <tr><td>tab</td> <td>标签页</td></tr> <tr><td>table</td> <td>表格</td></tr> <tr><td>txt,text</td> <td>文本</td></tr> <tr><td>thumbnail</td> <td>缩略图</td></tr> <tr><td>time</td> <td>时间</td></tr> <tr><td>tips</td> <td>提示</td></tr> <tr><td>title,tit</td> <td>标题</td></tr> <tr><td>video</td> <td>视频</td></tr> <tr><td>wrap</td> <td>容器，包，一般用于最外层</td></tr> <tr><td>wrapper</td> <td>容器，包，一般用于最外层</td></tr></tbody></table></div></section> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">10/9/2023, 2:58:10 PM</span></div></footer> <!----> <div class="comments-wrapper"><!----></div> <ul class="side-bar sub-sidebar-wrapper" style="width:12rem;" data-v-cb1513f6><li class="level-2" data-v-cb1513f6><a href="/sjj-blog/blogs/standards/name-standards.html#命名严谨性" class="sidebar-link reco-side-命名严谨性" data-v-cb1513f6>命名严谨性</a></li><li class="level-2" data-v-cb1513f6><a href="/sjj-blog/blogs/standards/name-standards.html#项目命名" class="sidebar-link reco-side-项目命名" data-v-cb1513f6>项目命名</a></li><li class="level-2" data-v-cb1513f6><a href="/sjj-blog/blogs/standards/name-standards.html#目录命名" class="sidebar-link reco-side-目录命名" data-v-cb1513f6>目录命名</a></li><li class="level-2" data-v-cb1513f6><a href="/sjj-blog/blogs/standards/name-standards.html#js、css、scss、html、png-文件命名" class="sidebar-link reco-side-js、css、scss、html、png-文件命名" data-v-cb1513f6>JS、CSS、SCSS、HTML、PNG 文件命名</a></li><li class="level-2" data-v-cb1513f6><a href="/sjj-blog/blogs/standards/name-standards.html#classname命名" class="sidebar-link reco-side-classname命名" data-v-cb1513f6>ClassName命名</a></li><li class="level-3" data-v-cb1513f6><a href="/sjj-blog/blogs/standards/name-standards.html#基于姓氏命名法-继承-外来" class="sidebar-link reco-side-基于姓氏命名法-继承-外来" data-v-cb1513f6>基于姓氏命名法 （继承 + 外来）</a></li><li class="level-3" data-v-cb1513f6><a href="/sjj-blog/blogs/standards/name-standards.html#模块命名" class="sidebar-link reco-side-模块命名" data-v-cb1513f6>模块命名</a></li><li class="level-3" data-v-cb1513f6><a href="/sjj-blog/blogs/standards/name-standards.html#常用命名推荐" class="sidebar-link reco-side-常用命名推荐" data-v-cb1513f6>常用命名推荐</a></li></ul></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div></div></div>
    <script src="/sjj-blog/assets/js/app.ab5bad9b.js" defer></script><script src="/sjj-blog/assets/js/3.136f62ef.js" defer></script><script src="/sjj-blog/assets/js/1.a27fba8e.js" defer></script><script src="/sjj-blog/assets/js/18.2237a65f.js" defer></script>
  </body>
</html>
